<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-xs layui-btn-danger data-count-add" lay-event="chakan">查看流程图</a>
        </script>

    </div>
</div>

<script src="../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        table.render({
            elem: '#currentTableId',
            url: '/processDefinition/list',
            toolbar: '#toolbarDemo',
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            skin: 'line',
            page:true,
            cols: [[
                {field:'zizeng',  title: '序号',width: 80,align:'center',templet:function (d) {
                        return d.LAY_TABLE_INDEX+1;
                    }},
                {field: 'id', width: 180, title: '编号',align:'center'},
                {field: 'name', width: 180, title: '流程名称',align:'center'},
                {field: 'key', width: 180, title: '流程定义的key',align:'center'},
                {field: 'version', width: 80, title: '版本',align:'center'},
                {field: 'resourceName', width: 200, title: '流程定义的规则文件名称',align:'center'},
                {field: 'diagramResourceName', width: 200, title: '流程定义的规则图片名称',align:'center'},
                {field: 'deploymentId', width: 120, title: '流程部署Id',align:'center'},
                {title: '操作', minWidth: 100, toolbar: '#currentTableBar', align: 'center'}
            ]],
            parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.rows //解析数据列表
                };
            }
        });

        //监听单元格事件
        table.on('tool(currentTableFilter)', function(obj){
            switch (obj.event) {
                case 'chakan':
                    var index = layer.open({
                        title: '查看当前流程图',
                        type: 2,
                        area: ['1100px', '600px'],
                        content: '../../processDefinition/showView?deploymentId='+obj.data.deploymentId+'&diagramResourceName='+obj.data.diagramResourceName
                    });
                    break;

            }

        });


    });

</script>

</body>
</html>